package com.turing.selfwebservice.common;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.GregorianCalendar;

import javax.xml.datatype.XMLGregorianCalendar;

public class Toolkit {
	public Toolkit() {
	}

	/**
	 * 处理null
	 * 
	 * @param s
	 * @return
	 */
	public static String dealNull(String s) {
		String s1 = null;

		if (s == null || s.equals("null")) {
			s1 = "";
		} else {
			s1 = s.trim();
		}

		return s1;
	}

	public static String dateTostring() {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		Date dt = new Date();
		return formatter.format(dt);
	}

	public static String dateTostring(Date dt) {
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		java.util.Date d = new java.util.Date();
		return formatter.format(dt);
	}

	public static Date convertToDate(XMLGregorianCalendar cal) throws Exception {
		GregorianCalendar ca = cal.toGregorianCalendar();
		return ca.getTime();
	}
}